import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { configParams } from '../storage-config';

@Injectable({
  providedIn: 'root'
})
export class StorageCommonService {

  headers = configParams.headers;

  serviceUrls: any = {
    queryWarehouseListUrl: '/whPut/list', // 查询仓库
    queryLocationListUrl: '/library/list', // 查询库位
    queryWhlistUrl: '/whGoods/list', // 查询仓储商品
    queryBomListUrl: '/whGoods/listBoom', // BOM选择
    updateExamineUrl: '/warehousing/audit', // 审核(入库单)
  };

  constructor(public httpClient: HttpClient) {}

  // 查询仓库
  getWarehouseList(params: any) {
    return this.httpClient.post(this.serviceUrls.queryWarehouseListUrl, params, {headers: this.headers}).toPromise();
  }

  // 查询库位
  getLocationList(params: any) {
    return this.httpClient.post(this.serviceUrls.queryLocationListUrl, params, {headers: this.headers}).toPromise();
  }

  // 查询仓储商品
  getWhlistData(params: any) {
    return this.httpClient.post(this.serviceUrls.queryWhlistUrl, params, {headers: this.headers}).toPromise();
  }

  // 查询Bom
  getBomList(params: any) {
    return this.httpClient.post(this.serviceUrls.queryBomListUrl, params, {headers: this.headers}).toPromise();
  }

  /**
   * 审核(入库单)
   * @param params 
   * @returns 
   */
  updateExamineData(params: any) {
    return this.httpClient.post(this.serviceUrls.updateExamineUrl, params, {headers: this.headers}).toPromise();
  }
}



